package com.example.goodog.customViews;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.View;

import com.example.goodog.R;

public class DriveToButton extends ListViewButton {

	private double Latitude, Longitude;
	
	public DriveToButton(Context c, double i_Latitude, double i_Longitude) {
		super(c,R.drawable.drive);
		
		Latitude = i_Latitude;
		Longitude = i_Longitude;
		
		this.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {

				try
				{
					String lat = String.valueOf(Latitude);
					String lon = String.valueOf(Longitude);
					
					String uri = "geo: "+lat+","+lon;
					((Activity)(v.getContext())).startActivity(new Intent(android.content.Intent.ACTION_VIEW,
					                        Uri.parse(uri)));

				}
				catch ( ActivityNotFoundException ex  )
				{
					
				}
			}
		});
	}
}
